<template>
    <my-list :data="tasks" ref="list" :page-size="12" :noQueryPart="true">
        <el-table-column label="任务名称" align="left" prop="jobName" width="240">
        </el-table-column>
        <el-table-column label="进度" align="left" class-name="cell-flex">
            <template v-slot="scope">
                <jenkins-log value="scope.row"></jenkins-log>
            </template>
        </el-table-column>
    </my-list>
</template>

<script setup>
import jenkinsLog from "./jenkins_log.vue"




//定义 vue2的this,当前组件
const $self = getCurrentInstance();

//定义 $attrs
const $attrs = useAttrs();



//定义data
const $data = reactive({"log_visible":false,"logs":{"steps":[],"result":""},"log":{},"pendding":false,"tasks":[]});


const $props = defineProps({
    type : { type: String },
    active : { type: Boolean }
});





const list = ref();

//定义事件
const $emit = defineEmits(["update:modelValue","loaded"]);



const pop_msg = function(item) {
    $data.log = item;
    $data.log_visible = true;
};
const load = function() {
    jv.$http.post("/dev/jenkins/tasks?type=" + $props.type, {}).then(res => {
        $data.tasks = res.data.data;
    });
};
const getLog = function() {
    jv.$http.post("/dev/jenkins/last-log", {
        gitId: $model.gitId,
        branch: $model.branch,
        appName: $model.appName
    }).then(res => {
        if (!res.data.data) {
            jv.warn("服务器没有返回内容")
            return;
        }
        if (res.data.data && res.data.data.length) {
        }
        $data.logs.steps = res.data.data.map(it => {
            var status = "wait";
            if (it.successful === true) {
                status = "success"
            } else if (it.successful === false) {
                status = "error"
            }
            return {title: it.name, content: it.content, status: status}
        });
        $data.logs.result = res.data.value;
        $data.logs.step = $data.logs.steps.length;
        if (res.data.value === true) {
            return
        } else if (res.data.value === false) {
            return
        }
    });
};

onMounted( function() {
    load();
} )



</script>

<style lang="scss">
.el-step__main {
    zoom: 0.8;
}
</style>
